const express = require('express')
const router = express.Router()
const merchantDao = require('../dao/MerchantDao')

router.post('/add', function (req, res) {
  let merchantName = req.body.merchantName
  let business = req.body.business
  let addressComponents = req.body.addressComponents
  let surroundingPois = req.body.surroundingPois
  let point = req.body.point
  merchantDao.add(merchantName, business, addressComponents, surroundingPois, point, function (result) {
	  res.send(result);
    res.end();
  });
})

router.post('/list', function (req, res) {
  let searchMap = req.body.searchMap
  merchantDao.list(searchMap, function (result) {
	  res.send(result);
    res.end();
  });
})

router.post('/delete', function (req, res) {
  let id = req.body.id
  merchantDao.delete(id, function (result) {
	  res.send(result);
    res.end();
  });
})

module.exports = router